package com.mentaleye.dal.dao.mybatis;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.mentaleye.dal.dao.DormitoryDao;
import com.mentaleye.dal.model.Dormitorys;
import com.mentaleye.dal.model.DormitorysExample;
import com.mentaleye.dal.service.DormitorysMapper;
@Component
public class DormitoryDaoImpl extends BaseDao implements DormitoryDao {

	@Autowired private DormitorysMapper dormitoryMapper;
	@Override
	public boolean insertDormitory(Dormitorys dormitory) {
		return getResultByInt(dormitoryMapper.insertSelective(dormitory));
	}

	@Override
	public boolean modifyDormitory(Dormitorys dormitory) {
		return getResultByInt(dormitoryMapper.updateByPrimaryKeySelective(dormitory));
	}

	@Override
	public boolean deleteDormitory(List<Integer> dorId) {
		DormitorysExample example = new DormitorysExample();
		example.createCriteria().andDorIdIn(dorId);
		return getResultByInt(dormitoryMapper.deleteByExample(example));
	}

	@Override
	public List<Dormitorys> queryAllDormitory() {
		DormitorysExample dormitorysExample = new DormitorysExample();
		return dormitoryMapper.selectByExample(dormitorysExample);
	}

	@Override
	public List<Dormitorys> queryDormitory(Map<String, Object> map) {
		return dormitoryMapper.selectByMap(map);
	}

	@Override
	public Dormitorys queryDormitoryById(Integer dorId) {
		return dormitoryMapper.selectByPrimaryKey(dorId);
	}

	@Override
	public List<Dormitorys> queryDormitoryWithRest() {
		return dormitoryMapper.selectDormitoryWithRest();
	}


}
